package d6_map_impl;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

//方式一: 事项Comparable接口, 重写比较规则
@Data // Data自带了无参 + get + set + toString + hashCode + equlas
@NoArgsConstructor//无参构造器
@AllArgsConstructor//写了有参构造器,就不会再提供无参构造器,如果还需要无参构造器就要进行写,
public class Movie implements Comparable<Movie>{
    private String name;
    private double score;
    private String actor;

  /*  @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Movie movie = (Movie) o;
        return Double.compare(movie.score, score) == 0 && Objects.equals(name, movie.name) && Objects.equals(actor, movie.actor);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, score, actor);
    }



    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public double getScore() {
        return score;
    }

    public void setScore(double score) {
        this.score = score;
    }

    public String getActor() {
        return actor;
    }

    public void setActor(String actor) {
        this.actor = actor;
    }

    public Movie() {
    }

    public Movie(String name, double score, String actor) {
        this.name = name;
        this.score = score;
        this.actor = actor;
    }*/
    @Override
    public String toString() {
        return "Movie{" +
                "name='" + name + '\'' +
                ", score=" + score +
                ", actor='" + actor + '\'' +
                '}' +"\n";
    }

    @Override
    public int compareTo(Movie o) {
        return Double.compare(getScore(),o.getScore());
    }
}
